<?php

use App\Http\Middleware\RequestMini;
use App\Http\Middleware\ResponseMini;
use App\Http\Middleware\VerifyMiniToken;
use farm\FarmRegister;
use farm\service\Crop;
use farm\utils\ApiUtils;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
Route::middleware([RequestMini::class, VerifyMiniToken::class, ResponseMini::class])->group(function () {
//    Route::resource("login", );
    Route::post('/upload', function (Request $request) {
        return ApiUtils::upload($request);
    });
    Route::post('/register', [FarmRegister::class, 'register'])->withoutMiddleware(VerifyMiniToken::class);
    Route::any('/video', function (Request $request) {

    });
    Route::any('/test', function (Request $request) {
        $data = $this->app->database;
        var_dump($data);
    })->withoutMiddleware(VerifyMiniToken::class);

    Crop::route();
});
